<?php
/**
 * Created by PhpStorm.
 * User: xiaomeng
 * Date: 17-9-18
 * Time: 下午4:20
 */
namespace swf\common;


class User
{
    private $curl = null;
    private $url = "https://www.funhainan.net:9030/api/ZhangYu/GetUserName";

    public function __construct()
    {
        $this->curl = new Curl();
    }


    public function getUserInfo($userId)
    {
        $url = $this->getUrl($userId);
        $res = $this->curl->get($url);
        $data = $this->decodeData($res);
        $data['ico'] = Utils::getM($userId,4);//头像
        return $data;
    }

    private function getUrl($userId)
    {
        return $this->url.'?userId='.$userId;
    }

    /**
     * 解析数据
     * @param $data
     * @return mixed
     */
    private function decodeData($data)
    {
        return json_decode($data,true);
    }
}
